﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
namespace AllInfoC
{
    class Main
    {
        public Main()
        {
            var config = new XmlDocument();
            config.Load("config.xml");
            var xmlNodeList = config.GetElementsByTagName("website");
            var infos = new List<string>();
            foreach (XmlNode xmlNode in xmlNodeList)
            {
                //Console.WriteLine(xmlNode.OuterXml);
                Console.WriteLine(xmlNode.FirstChild.InnerText);
                Console.WriteLine(xmlNode.LastChild.InnerText);
                var url = xmlNode.FirstChild.InnerText;
                var xpath = xmlNode.LastChild.InnerText;
                var webInfo = new WebInfo(url, xpath);
                webInfo.GetInfo();
                infos.Add(webInfo.ToString());
                //Console.WriteLine(webInfo.ToString());
            }
            
            var tplMain = File.ReadAllText(@"tplMain.htm");
            var outPut = String.Format(tplMain, infos.ToArray());
            //Console.WriteLine(outPut);
            File.WriteAllText(@"index.htm", outPut);
            Console.Read();
        }
    }
}
